const BaseHandler = require('../base-handler');
const HTTP_VERBS = require('../../../constants').HTTP_VERBS;

class BlueMPRedirectHandler extends BaseHandler {

    get pattern() {
        return "/bluemp/redirect";
    }

    doGET(request, response) {
        let redirectURI = this.Controller.getRedirectURI(request);
        let mpRedirectURL = this.Controller.getAuthorizeURL(redirectURI);

        response.redirect(mpRedirectURL);
    }

    setup() {
        this.registerVerb(HTTP_VERBS.GET, this.doGET);
    }
}

module.exports = BlueMPRedirectHandler;